package cn.chencaiju.spring;

import java.text.DateFormat;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PostService {
	private String name;
	private PostDao dao;
	
	/*@Autowired
	@Qualifier("service2")*/
	@Resource(name="service1")
	private AnnoInterface inter;
	
	@Autowired
	DateFormat dateFormat;
	
	public void dateform() {
		System.out.println(dateFormat.format(new Date()));
	}
	
	public void setDao(PostDao dao) {
		this.dao=dao;
	}
	public PostService(String name) {
		this.name=name;
	}
	public PostService() {
		System.out.println("service had initlized!");
	}
	public void delete() {
		System.out.println("service run the delete!");
		dao.delete();
	}
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("PostService [name=");
		builder.append(name);
		builder.append(", dao=");
		builder.append(dao);
		builder.append(",service=");
		builder.append(inter);
		builder.append("]");
		return builder.toString();
	}
	
}
